home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung (Tewi)(1994).iso / magazine / dbms_mag / 9108 / bench3.aug < prev    next >
Text File  |  1991-07-19  |  4KB  |  96 lines

  1. Listing 3
  2.  
  3.  
  4. /*-------------------------------------------------------------------------*/
  5. /*                                                                         */
  6. /* Oracle OCI Transaction #14  v1.2                                        */
  7. /*                                                                         */
  8. /* Copyright (c) 1991 - M&T Publishing                                     */
  9. /*                                                                         */
  10. /* Programmer : Brian Butler                                               */
  11. /*                                                                         */
  12. /* Description:  Add New Account                                           */
  13. /*                                                                         */
  14. /* Input Fields:                                                           */
  15. /*                                                                         */
  16. /*      AccountID   char(10)                                               */
  17. /*      AccountName char(33)                                               */
  18. /*      AccountType char(4)                                                */
  19. /*                                                                         */
  20. /*-------------------------------------------------------------------------*/
  21.  
  22. #include "ocidef.h"
  23.  
  24. extern char AccountID  [11];
  25. extern char Account    [33];
  26. extern char AccountType[4];
  27.  
  28. long Transaction14 (USHORT usLevel,USHORT usGroup,FILE *df, struct csrdef *cursor)
  29. {
  30.    struct DataFileRecord14 DFR;
  31.  
  32.    if (fread((char *) &DFR,sizeof(DFR),1,df) > 0) {
  33.       Status.Input[14]++;
  34.  
  35.       strncpy(AccountID, DFR.AcctID, 9);
  36.       strtrim(AccountID, 10);
  37.  
  38.       strncpy(Account, DFR.AcctName, 32);
  39.       strtrim(Account, 33);
  40.  
  41.       strncpy(AccountType, DFR.AcctType, 3);
  42.       strtrim(AccountType, 4);
  43.  
  44.       if (Status.ShowHeader == TRUE)
  45.        {
  46.          printf ("\n\nOracle 6.0 (OCI) =- Transaction #14 - Add New Account -= [%ld]\n\n",Status.Input[14]);
  47.          printf ("AccountID: %s:\n"   ,AccountID);
  48.          printf ("Account Name: %s:\n",Account);
  49.          printf ("Account Type: %s:\n",AccountType);
  50.        }
  51.  
  52.       /*-------------------------------------------*/
  53.       /*                                           */
  54.       /*   TRANSACTION 14: Add New Account         */
  55.       /*                                           */
  56.       /*-------------------------------------------*/
  57.  
  58.       SetStartTime();
  59.  
  60.       if (osql3 (cursor,
  61.  
  62.       "INSERT INTO Accounts (ID,Name,Type) \
  63.        VALUES (:AccountID,:Account,:AccountType)",-1)
  64.  
  65.       || obndrv (cursor,":AccountID",   -1,AccountID,  sizeof(AccountID),  CHRSTR,-1,(short *)-1,(char *)-1,-1,-1)
  66.       || obndrv (cursor,":Account",     -1,Account,    sizeof(Account),    CHRSTR,-1,(short *)-1,(char *)-1,-1,-1)
  67.       || obndrv (cursor,":AccountType", -1,AccountType,sizeof(AccountType),CHRSTR,-1,(short *)-1,(char *)-1,-1,-1))
  68.          {
  69.          ShowError (cursor,"14001 - Parse/Bind of Insert Accounts failed",14);
  70.          goto Op14Failed;
  71.          }
  72.  
  73.       oexec (cursor);
  74.  
  75.       if (cursor->csrarc != SUCCESS)
  76.          {
  77.          ShowError(cursor,"14001 - Insert into Accounts failed.",14);
  78.          goto Op14Failed;
  79.          }
  80.  
  81.       ocom (&LDA);   /* EXEC SQL COMMIT WORK */
  82.  
  83.       SetEndTime(usLevel,14,usGroup,1L);
  84.  
  85.       return(1L);
  86.  
  87. Op14Failed:
  88.       orol (&LDA); /* EXEC SQL ROLLBACK WORK; */
  89.  
  90.       SetEndTime(usLevel,14,usGroup,-1L);
  91.  
  92.       return(-1L);
  93.    }
  94.    return((long) EOF);
  95. }
  96.